package com.itheima.user;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

public class Test {
    public static void main(String[] args) throws IOException {
        //掌握Properties类属性文件的数据解析
        //创建Properties对象
        Properties pro = new Properties();
        //将指定的属性文件加载到Properties对象中
        pro.load(new FileInputStream("D:\\java-base-ws\\JavaAdvanceProject\\day15_Properties\\src\\com\\itheima\\user\\user.properties"));

        //读取数据
        //方式一：键找值
        pro.getProperty("name");
        System.out.println(pro.getProperty("name"));

        //方式二：键值对
        Set<Map.Entry<Object, Object>>entries= pro.entrySet();
        for (Map.Entry<Object, Object> entry : entries) {
            System.out.println(entry.getKey() + "=" + entry.getValue());
        }

        //方式三：lamda
        pro.forEach((k,v)-> System.out.println(k + "=" + v));
    }
}
